package com.fz.us.admin.company.service;

import com.fz.us.admin.base.bean.Result;
import com.fz.us.admin.base.service.BaseService;
import com.fz.us.admin.company.entity.Company;
import com.fz.us.admin.company.entity.Department;
import com.fz.us.admin.company.entity.User;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Service接口 - 部门
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-02 。
 * ============================================================================
 */
public interface DepartmentService extends BaseService<Department, String> {

    /**
     * 获取公司下的所有部门列表
     *
     * @param company 企业
     * @return
     */
    public List<Department> getAllDepartments(Company company);

    /**
     * 获取公司下的顶级部门列表
     *
     * @param company 企业
     * @return
     */
    public List<Department> getRootDepartments(Company company);

    /**
     * 获取部门下的部门列表
     *
     * @param company 企业
     * @param department 部门
     * @return
     */
    public List<Department> getDepartments(Company company, Department department);

    /**
     * 是否有下级部门
     *
     * @param department
     * @return
     */
    public boolean isParentDepartment(Department department);

    /**
     * 保存
     *
     * @param user
     * @param department
     * @return
     */
    public Result createEntity(User user, Department department);

    /**
     * 修改
     *
     * @param user
     * @param department
     * @return
     */
    public Result updateEntity(User user, String keyId, Department department);

    /**
     * 操作
     *
     * @param user
     * @param method
     * @param keyId
     * @return
     */
    public Result methodEntity(User user, String method, String keyId);

    /**
     * 拖入
     *
     * @param user
     * @param keyId
     * @param targetId
     * @return
     */
    public Result dropInnerEntity(User user, String keyId, String targetId);

    /**
     * 列表 Map
     *
     * @param department
     * @return
     */
    public Map<String, Object> getListMap(Department department);

    /**
     * 详情 Map
     *
     * @param department
     * @return
     */
    public Map<String, Object> getDetailMap(Department department);

    /**
     * tree Map
     *
     * @param department
     * @return
     */
    public Map<String, Object> getTreeMap(Department department);

    /**
     * 企业下部门 Map Tree
     *
     * @param company
     * @return
     */
    public List<Map<String, Object>> getTreeMapList(Company company);

    /**
     * 根据名称查找
     *
     */
    public List<Department> getDepartments(String name);

    public Set<Department> getChildDepart(Department department, Set<Department> set);

}
